﻿<Window x:Class="proj4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:proj4"
        Title="Puzzle" Height="600" Width="800" Icon="icon.ico" MinHeight="450" MinWidth="600"
        DataContext="{Binding RelativeSource={RelativeSource Self}}" Closed="Window_Closed" Loaded="Window_Loaded">
    <Window.Resources>
        <local:BoolToStringConverter x:Key="BooleanToStringConverter" FalseValue="Start Game" TrueValue="End Game" />
        <local:BoolToVisibilityConverter x:Key="BooleanToVisibilityConverter" FalseValue="Hidden" TrueValue="Visible" />
        <local:BoolToIntConverter x:Key="BoolToIntConverter"  />
        <Style x:Key="listViewStyle" TargetType="ListView">
            <Setter Property="Margin" Value="10, 50, 10, 10"/>
        </Style>
        <Style x:Key="labelStyle" TargetType="Label">
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="0, 8, 0, 0"/>
            <Setter Property="FontSize" Value="20"/>
        </Style>
    </Window.Resources>
    <DockPanel LastChildFill="True" >
        <TabControl >
            <TabItem Header="Game">
                <Grid Name="mainGrid" Background="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="343*"/>
                        <ColumnDefinition Width="85"/>
                    </Grid.ColumnDefinitions>


                    <Canvas Name="picture" Grid.Column="0"  Background="#FF9EBDDE" Margin="23,25,23,46" Canvas.Left="0" Canvas.Top="0" SizeChanged="picture_SizeChanged" >
                    </Canvas>

                    <StackPanel Grid.Column="1"  Orientation="Vertical" Width="65" HorizontalAlignment="Center" VerticalAlignment="Top" >
                        <Button Name="startButton" Content="{Binding IsEnabled, ElementName=pauseButton, Mode=OneWay, Converter={StaticResource BooleanToStringConverter}}" Margin="0,30,0,0" Height="40" Click="startButton_Click" />
                        <Button Name="pauseButton" Content="Pause" Margin="0,15,0,0" Height="40" IsEnabled="False" Click="pauseButton_Click" />
                        
                        <GroupBox Panel.ZIndex="0" Grid.Column="1" Header="Puzzle Size"  Margin="-13,20,-13,0" HorizontalAlignment="Center" Height="110" Width="78"  >
                            <StackPanel>
                                <RadioButton Content="Hard" Height="20" VerticalAlignment="Top" Margin="0,0,0,10" IsChecked="{Binding Path=puzzleSize, Mode=TwoWay, Converter={StaticResource BoolToIntConverter}, ConverterParameter=50}"/>
                                <RadioButton Content="Medium" Height="20" VerticalAlignment="Top" IsChecked="{Binding Path=puzzleSize, Mode=TwoWay, Converter={StaticResource BoolToIntConverter}, ConverterParameter=75}"/>
                                <RadioButton Content="Easy" Height="20" VerticalAlignment="Top" Margin="0,10,0,0" IsChecked="{Binding Path=puzzleSize, Mode=TwoWay, Converter={StaticResource BoolToIntConverter}, ConverterParameter=150}"/>
                            </StackPanel>
                        </GroupBox>
                    </StackPanel>

                    <DockPanel Grid.ColumnSpan="2" Height="20" VerticalAlignment="Bottom">
                        <StatusBar  DockPanel.Dock="Right">
                            <StatusBarItem Name="timeBar" Visibility="{Binding IsEnabled, ElementName=pauseButton, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"  HorizontalAlignment="Right" Content="Time: 00:00:00" />
                        </StatusBar>
                    </DockPanel>
                    <Image Panel.ZIndex="1" Name="pauseImage" Grid.ColumnSpan="2" Opacity="0.8" Stretch="Fill" Visibility="Hidden" Source="pause.png">
                        <Image.Triggers>
                            <EventTrigger RoutedEvent="MouseDown"  >
                                <BeginStoryboard>
                                    <Storyboard FillBehavior="Stop">
                                        <DoubleAnimation  
                                            Storyboard.TargetProperty="Opacity"
                                            To="0.0"
                                            Completed="Story_Completed" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                        </Image.Triggers>
                    </Image>
                </Grid>
            </TabItem>
            
            <TabItem Header="High scores">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="246*"/>
                        <ColumnDefinition Width="246*"/>
                        <ColumnDefinition Width="246*"/>
                    </Grid.ColumnDefinitions>
                    
                    <Grid.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#FF5143D8" Offset="0"/>
                            <GradientStop Color="#FF1C9C4B" Offset="0.7"/>
                        </LinearGradientBrush>
                    </Grid.Background>
                    
                    <Label Grid.Column="0" Content="Easy" Style="{StaticResource labelStyle}"/>
                    <Label Grid.Column="1" Content="Medium" Style="{StaticResource labelStyle}"/>
                    <Label Grid.Column="2" Content="Hard" Style="{StaticResource labelStyle}"/>
                    
                    <ListView ItemsSource="{Binding EasyResult}" Name="easy" Grid.Column="0" Style="{StaticResource listViewStyle}" >
                        <ListView.View >
                            <GridView>
                                <GridViewColumn DisplayMemberBinding="{Binding Name}" Width="Auto" Header="Name" />
                                <GridViewColumn DisplayMemberBinding="{Binding Count}" Width="50" Header="Count" />
                                <GridViewColumn DisplayMemberBinding="{Binding Time}" Width="50" Header="Time (s)" />
                            </GridView>
                        </ListView.View>
                    </ListView>
                    
                    <ListView ItemsSource="{Binding MediumResult}" Name="medium" Grid.Column="1" Style="{StaticResource listViewStyle}">
                        <ListView.View >
                            <GridView>
                                <GridViewColumn DisplayMemberBinding="{Binding Name}" Width="Auto" Header="Name" />
                                <GridViewColumn DisplayMemberBinding="{Binding Count}" Width="50" Header="Count" />
                                <GridViewColumn DisplayMemberBinding="{Binding Time}" Width="50" Header="Time (s)" />
                            </GridView>
                        </ListView.View>
                    </ListView>
                    
                    <ListView ItemsSource="{Binding HardResult}" Name="hard" Grid.Column="2" Style="{StaticResource listViewStyle}">
                        <ListView.View >
                            <GridView>
                                <GridViewColumn DisplayMemberBinding="{Binding Name}" Width="Auto" Header="Name" />
                                <GridViewColumn DisplayMemberBinding="{Binding Count}" Width="50" Header="Count" />
                                <GridViewColumn DisplayMemberBinding="{Binding Time}" Width="50" Header="Time (s)" />
                            </GridView>
                        </ListView.View>
                    </ListView>
                </Grid>

            </TabItem>
        </TabControl>




    </DockPanel>




</Window>
